//
//  CourseDetailTeacherCell.m
//  ShowYork
//
//  Created by hxh on 2020/9/2.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "LessonDetailTeacherCell.h"

@interface LessonDetailTeacherCell ()
@property (nonatomic,strong)UIImageView *teacherIcon;
@property (nonatomic,strong)UILabel *teacherNameLb;
@property (nonatomic,strong)UILabel *descLb;
@property (nonatomic,strong)UIImageView *nextImgView;
@property (nonatomic,strong)UIImageView *teacherTypeImgView;
@end

@implementation LessonDetailTeacherCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUI];
    }
    return self;
}
- (void)setUI{

    
    self.teacherIcon = [[UIImageView alloc]init];
    self.teacherIcon.image = [UIImage imageNamed:@"defaut_header"];
    self.teacherIcon.layer.cornerRadius = 30;
    self.teacherIcon.layer.masksToBounds = YES;
    [self.contentView addSubview:self.teacherIcon];
    

    self.teacherNameLb = [[UILabel alloc]init];
    self.teacherNameLb.textColor = RGBA(35, 24, 21, 1);
    self.teacherNameLb.font = font(14);
    [self.contentView addSubview:self.teacherNameLb];
    
    self.descLb = [[UILabel alloc]init];
    self.descLb.textColor = C153;
    self.descLb.font = font(12);
    self.descLb.numberOfLines = 2;
    [self.contentView addSubview:self.descLb];

    [self.teacherIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(60, 60));
        make.bottom.equalTo(self.contentView).offset(-16);
        make.top.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(16);
    }];
    
    
    self.teacherTypeImgView = [[UIImageView alloc]init];
    [self.contentView addSubview:self.teacherTypeImgView];
    
    [self.teacherNameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.teacherIcon);
        make.left.equalTo(self.teacherIcon.mas_right).offset(16);
    }];
    
    self.nextImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"course_tag_next"]];
    [self.contentView addSubview:self.nextImgView];
    
    [self.nextImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(-16);
    }];
    
    [self.descLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.teacherNameLb.mas_bottom).offset(4);
        make.left.equalTo(self.teacherIcon.mas_right).offset(16);
        make.right.equalTo(self.contentView).offset(-33);
        make.bottom.equalTo(self.teacherIcon);
    }];
    [self.teacherTypeImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.teacherNameLb.mas_right).offset(8);
        make.centerY.equalTo(self.teacherNameLb);
    }];

}
- (void)setModel:(AccountModel *)model{
    [self.teacherIcon sd_setImageWithURL:[NSURL URLWithString:model.head] placeholderImage:[UIImage imageNamed:@"defaut_header"]];
    self.teacherNameLb.text = model.name;
    self.descLb.text = model.intro;
    if (self.tag == 0) {
        self.teacherTypeImgView.image = [UIImage imageNamed:@"course_leader_tag"];
    }else{
        self.teacherTypeImgView.image = [UIImage imageNamed:@"course_teaching_tag"];
    }
}
- (void)setCourseDetailLeader:(LessonLeaderModel *)leader{
    [self.teacherIcon sd_setImageWithURL:[NSURL URLWithString:leader.imagePath] placeholderImage:[UIImage imageNamed:@"defaut_header"]];
    self.teacherNameLb.text = leader.userName;
    self.descLb.text = leader.intro;
    self.teacherTypeImgView.image = [UIImage imageNamed:@"course_leader_tag"];
}
- (void)setCourseDetailTeacher:(AccountModel *)teacher{
    [self.teacherIcon sd_setImageWithURL:[NSURL URLWithString:teacher.head] placeholderImage:[UIImage imageNamed:@"defaut_header"]];
    self.teacherNameLb.text = teacher.name;
    self.descLb.text = teacher.intro;
    self.teacherTypeImgView.image = [UIImage imageNamed:@"course_teaching_tag"];
}
@end
